"""
网站 ==http://tool.liumingye.cn/music/?page=audioPage&type=migu&name=%E5%91%A8%E6%9D%B0%E4%BC%A6
"""
import re

import requests
import execjs

url = "http://59.110.45.28/m/api/search"
search_text = "周杰伦"
page = 1
type = "migu"
headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
    "Origin": "http://tool.liumingye.cn"
}
with open("js_1.js", "r",encoding="UTF-8")as f:
    info = f.read()

exec_js = execjs.compile(info)
a=f"text={search_text}&page={page}&type={type}"
datas = exec_js.call("waw",a)  # 加密
# data=445b7M3UbPPg_CZx3MGONnNi8CzJB7V5wIOLZdSjeZV2R90KjCPJAV43zFyastL5rOvolIy8d0aNzKVb&v=2

data = {
    "data": re.findall("data=(.*?)&.*?",datas,re.S)[0],
    "v": 2
}
resp = requests.post(url, data=data, headers=headers)
print(resp.text)
